﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace AIC_CD
{
    public partial class FormXemVanBan : System.Web.UI.Page
    {
        private static int ID = 0;
        private static string FilePath = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["ID"] != null)
            {
                ID = Convert.ToInt32(Request.QueryString["ID"].ToString());
                string sql = "SELECT * FROM dbo.tblTaiLieu WHERE IDTaiLieu = @ID";
                List<SqlParameter> lstParameter = new List<SqlParameter>();
                lstParameter.Add(SqlHelper.CreateParameterObject("@ID", SqlDbType.Int, ParameterDirection.Input, ID));
                DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql, lstParameter);
                lblTrichYeu.Text = dt.Rows[0]["TrichYeu"].ToString();
                lblNgayBanHanh.Text = "Ngày ban hành : " + Convert.ToDateTime(dt.Rows[0]["NgayBanHanh"]).ToString("dd/MM/yyyy");
                lblNoiDung.InnerHtml = dt.Rows[0]["NoiDung"].ToString();
                if (dt.Rows[0]["FileDinhKem"].ToString() != "")
                    lbtFileDinhKem.Text = dt.Rows[0]["FileDinhKem"].ToString().Split('/')[2];
                FilePath = dt.Rows[0]["FileDinhKem"].ToString();
            }
        }

        protected void lbtFileDinhKem_Click(object sender, EventArgs e)
        {
            if (lbtFileDinhKem.Text.Length != 0)
            {
                string FileName = lbtFileDinhKem.Text;
                MyCommon.Download(FileName, "userfiles/VanBan/" + FileName);
            }
        }

            
    }
}
